<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="common/header.jsp" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>新增一个项目</title>
</head>
<style>
.layui-input-block{
	width:40rem;
}
.layui-input-block{
	margin-bottom:1rem;
}
</style>

<body>

<form class="layui-form" action="${webRoot}/svn/e" style="padding:1rem;">
	<input name="id" type="hidden" value="${pro==null?0:pro.id}" />
	<div class="layui-form-item">
    <div class="layui-input-block">
		<input type="text" name="name" value="${pro.name}" required lay-verify="required" placeholder="请输入项目名称" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-input-block">
		<input type="text" name="svnDir" value="${pro.svnDir}" required lay-verify="required" placeholder="svn目录路径，如 c:/workspace/svn" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-input-block">
		<input type="text" name="localDir" value="${pro.localDir}" required lay-verify="required" placeholder="本地部署路径，如 c:/workspace/svn" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-input-block">
		<input type="text" name="patchDir" value="${pro.patchDir}" required lay-verify="required" placeholder="补丁存放路径，如 c:/workspace/svn" autocomplete="off" class="layui-input">
    </div>
  </div>
</form>

</body>
</html>
<script>

function submit(){
	var name = $('input[name=name]').val();
	if(name==''){
		layer.alert('项目名不得为空', {icon: 6});
		return false;
	}
	var svnDir = $('input[name=svnDir]').val();
	if(svnDir==''){
		layer.alert('svn目录路径不得为空', {icon: 6});
		return false;
	}
	var localDir = $('input[name=localDir]').val();
	if(localDir==''){
		layer.alert('本地部署路径不得为空', {icon: 6});
		return false;
	}
	var localDir = $('input[name=localDir]').val();
	if(localDir==''){
		layer.alert('本地部署路径不得为空', {icon: 6});
		return false;
	}
	var patchDir = $('input[name=patchDir]').val();
	if(patchDir==''){
		layer.alert('补丁存放路径不得为空', {icon: 6});
		return false;
	}
	var id = $('input[name=id]').val();
	
	$.ajax({
		url:'${webRoot}/svn/e',
		type:'post',
		async:false,
		data:{'name':name,'svnDir':svnDir,'localDir':localDir,'patchDir':patchDir,'id':id},
		success:function(data){
			if(data.success){
				layer.msg('数据编辑成功',{time:2000},function(){window.parent.winClose(true);});
			}else{
				layer.alert(data.msg, {icon: 6});
			}
		}
	});
	
}

</script>